#include<bits/stdc++.h>

using namespace std;
int dp[501][501];
long long cnt = 0;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;


	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			cin >> dp[i][j];
			dp[i][j] += dp[i - 1][j];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int ii = i; ii <= n; ii++)
		{
			int l = 1, r = 1, sum = 0;
			for (r = 1; r <= m; r++)
			{
				sum += dp[ii][r] - dp[i - 1][r];
				while (sum > k)
				{
					sum -= dp[ii][l] - dp[i - 1][l];
					l++;
				}
				cnt += r - l + 1;
			}
		}
	}

	cout << cnt;


	return 0;
}